package tokenizer;

import java.math.BigDecimal;
import java.math.MathContext;

/**
 * Token
 * 
 * @author moltenio
 *
 */
public class TokenNostro {
	
    public static enum Type {	
        
        Plus, Minus, // + -
    	Times, Div, // * /

        OpenParen, CloseParen, // ( )
        
        Semicolon, // ;
        
        Becomes, // = 
        
        Ident, // Identificatore
        Num, // Numero
        
        EOS // End Of Stream
    }

	private Type type;
	private String name;
	private BigDecimal num;
     
    

	// Costruttore
	public TokenNostro(Type type, String name, BigDecimal num) {
        this.type = type;
        this.name = name;
        this.num = num;
    }

	public TokenNostro(Type type) {
        this(type, null, null);
    }

    
    
    public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public BigDecimal getNum() {
		return num;
	}

	public void setNum(BigDecimal num) {
		this.num = num;
	}

	public void setType(Type type) {
		this.type = type;
	}

    public Type getType() {
        return type;
    }


    public static TokenNostro ident(String name) {
       return new TokenNostro(Type.Ident,  name, null);
    }

    public static TokenNostro number(String num) {
        return new TokenNostro(Type.Num, null, new BigDecimal(num));
    }

  

    public static TokenNostro simple(Type type) {
        return new TokenNostro(type, null, null);
    }
    
    public String toString(){
    	return this.type.toString() + " "+  this.num + " " + this.name;
    }
}
